import {Descriptions} from 'antd';
import React from 'react';
import {VehicleFuelType, VehicleStatus, VehicleTransmissionType, VehicleType} from "@/constants/VehicleConst";

interface VehicleDetailProps {
  data: API.IVehicle;
}

const VehicleDetail: React.FC<VehicleDetailProps> = ({data}) => {
  const getValueLabel = (value: any, map: Record<string, string>) => {
    return map[value] || value;
  };

  return (
    <Descriptions column={2} bordered>
      <Descriptions.Item label="车牌号码">{data.plateNumber}</Descriptions.Item>
      <Descriptions.Item label="车辆类型">{getValueLabel(data.vehicleType, VehicleType)}</Descriptions.Item>
      <Descriptions.Item label="品牌">{data.brand}</Descriptions.Item>
      <Descriptions.Item label="型号">{data.model}</Descriptions.Item>
      <Descriptions.Item label="颜色">{data.color}</Descriptions.Item>
      <Descriptions.Item label="生产日期">{data.productionDate}</Descriptions.Item>
      <Descriptions.Item label="购买日期">{data.purchaseDate}</Descriptions.Item>
      <Descriptions.Item label="发动机号">{data.engineNumber}</Descriptions.Item>
      <Descriptions.Item label="车架号">{data.frameNumber}</Descriptions.Item>
      <Descriptions.Item
        label="变速箱类型">{getValueLabel(data.transmissionType, VehicleTransmissionType)}</Descriptions.Item>
      <Descriptions.Item label="燃油类型">{getValueLabel(data.fuelType, VehicleFuelType)}</Descriptions.Item>
      <Descriptions.Item label="座位数">{data.seats}</Descriptions.Item>
      <Descriptions.Item label="当前里程">{data.mileage} 公里</Descriptions.Item>
      <Descriptions.Item label="状态">{getValueLabel(data.status, VehicleStatus)}</Descriptions.Item>
      <Descriptions.Item label="GPS设备ID">{data.gpsDeviceId || '-'}</Descriptions.Item>
      <Descriptions.Item label="保险单号">{data.insuranceNumber || '-'}</Descriptions.Item>
      <Descriptions.Item label="保险到期日">{data.insuranceExpire || '-'}</Descriptions.Item>
      <Descriptions.Item label="年检日期">{data.annualInspectionDate || '-'}</Descriptions.Item>
      <Descriptions.Item label="下次年检日期">{data.nextInspectionDate || '-'}</Descriptions.Item>
      <Descriptions.Item label="备注" span={2}>
        {data.remark || '-'}
      </Descriptions.Item>
    </Descriptions>
  );
};

export default VehicleDetail;
